<?php

namespace App\DataStore;

use App\Repository\RepositoryGeneral;
use Hyperf\Di\Annotation\Inject;
use Hyperf\Redis\Redis;

class RedisAgencyGeneral extends RepositoryGeneral
{
    #[Inject]
    public Redis $redis;

    // 延时通用
    public function expire(string $key,int $ttl){
        if ($this->redis->exists($key)) {
            $this->redis->expire($key,$ttl);
        }
    }

    public function getAgencyCompanySelect($key):string {
        return (string)$this->redis->get("agency:select:company:".$key);
    }

    public function setAgencyCompanySelect($key,$data){
        $this->redis->set("agency:select:company:".$key,jsonEncode($data));
    }



}